const purchaseModel = require('./model/purchaseModel')
const auditRecordModel = require('./model/auditRecordModel')
const dayjs = require('dayjs')


exports.loginDao = async function(info) {
    const res = await purchaseModel.findOne({
        a_email: info.a_email,
        a_password: info.a_password
    })
    return res
}

exports.insertAuditRecordDao = async function(info, user) {
    console.log('================== dao user', user);
    const obj = {
        user_id: info.c_id,
        audit_state: info.action,
        audit_time: dayjs(Date.now()).format('YYYY/MM/DD HH:mm:ss'),
        audit_desc: info.description,
        auditor: user.a_name
    }
    let audit = new auditRecordModel(obj)
    const res = await audit.save()
    console.log('--------------------- dao res', res);
    return res
}
